<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Transition</title>
    <link href="https://cdn.bootcss.com/twitter-bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdn.bootcss.com/animate.css/3.7.2/animate.min.css" rel="stylesheet">
    <style>
        .fade-enter-active,
        .fade-leave-active {
            transition: opacity .5s;
        }

        /* .fade-leave-active below version 2.1.8 */
        .fade-enter,
        .fade-leave-to {
            opacity: 0;
        }

        .list-item {
            display: inline-block;
            margin-right: 10px;
        }

        .list-enter-active,
        .list-leave-active {
            transition: all 1s;
        }

        .list-enter,
        .list-leave-to

        /* .list-leave-active for below version 2.1.8 */
            {
            opacity: 0;
            transform: translateY(30px);
        }

        .list-move {
            transition: transform 1s;
        }

        .list-item {
            transition: all 1s;
            display: inline-block;
            margin-right: 10px;
        }

        .list-enter,
        .list-leave-to

        /* .list-leave-active for below version 2.1.8 */
            {
            opacity: 0;
            transform: translateY(30px);
        }

        .list-leave-active {
            position: absolute;
        }
    </style>
</head>

<body>
    <div id="app">
        <button class="btn btn-primary" v-on:click="show = !show">
            Toggle
        </button>
        <transition appear name="fade" enter-active-class="animated tada" leave-active-class="animated bounceOutRight">
            <p v-if="show">Hello</p>
        </transition>

        <transition name="fade" mode="out-in">
            <button v-bind:key="isEditing" class="btn btn-warning" @click="toggle">
                {{ isEditing ? 'Save' : ' Edit '}}
            </button>
        </transition>
    </div>
    <div id="list-demo">
        <button v-on:click="add" class="btn btn-primary">Add</button>
        <button v-on:click="remove" class="btn btn-primary">Remove</button>
        <transition-group name="list" tag="p">
            <span v-for="item in items" v-bind:key="item" class="list-item">
                {{ item }}
            </span>
        </transition-group>

    </div>
</body>
<script src="./node_modules/vue/dist/vue.js"></script>
<script>
    var app = new Vue({
        el: '#app',
        data: {
            show: true,
            isEditing: false
        },
        methods: {
            toggle: function () {
                this.isEditing = !this.isEditing;
            }
        },
    });

    var listApp = new Vue({
        el: '#list-demo',
        data: {
            items: [1, 2, 3, 4, 5, 6, 7, 8, 9],
            nextNum: 10
        },
        methods: {
            randomIndex: function () {
                return Math.floor(Math.random() * this.items.length);
            },
            add: function () {
                this.items.splice(this.randomIndex(), 0, this.nextNum++);
            },
            remove: function () {
                this.items.splice(this.randomIndex(), 1);
            }
        },
    });
</script>

</html>